#!usr/bin/env python
#-*- coding:utf-8 _*-
"""
@author:田野
@time: 2018/12/17
"""
import os,django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_one.settings")# project_name 项目名称
django.setup()
from datetime import date

from booktest.models import BookInfo, HeroInfo


def createInfo():
    book = BookInfo(
        btitle='语文',
        bput_date=date(1988, 1, 1),
        bread=10,
        bcomment=10,
    )
    book.save()
    hero = HeroInfo(
        hname='图形孙',
        hgender=0,
        hbook=book
    )
    hero.save()
    hero2 = HeroInfo(
        hname='老猪',
        hgender=0,
        hbook_id=book.id
    )
    hero2.save()
    HeroInfo.objects.create(
        hname='老沙',
        hgender=0,
        hbook=book
    )
def search():
    print(BookInfo.objects.all().count())
    print(BookInfo.objects.get(btitle='西游记'))
    print(BookInfo.objects.get(id=3))
    print(BookInfo.objects.get(btitle='西游记').id)
    print(BookInfo.objects.filter(btitle='西游记'))
if __name__ == '__main__':
    # createInfo()
    search()